home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / MPW Goodies / MPW Goodies⁄DTS / CheckWindowIn < prev    next >
Text File  |  2022-08-05  |  4KB  |  155 lines

  1. #    CheckWindowIn - check a window in
  2. #
  3. #    Usage:    CheckWindowIn window
  4. #
  5. #    Status:    CheckWindowIn may return the following status values:
  6. #
  7. #            0        the window was checked in
  8. #            1        error
  9. #            4        the user canceled
  10. #
  11. #    CheckWindowIn presents a dialog that allows the user to type
  12. #    in a short comment that indicates what changes have been made
  13. #    to the file since it was checked out. These will be logged into
  14. #    the project, and, if the file has a LastChange marker, will be
  15. #    logged into the file.
  16. #
  17. #    © 1988, 1989 Apple Computer, Inc.
  18. #    All rights reserved.
  19.  
  20. Set Exit 0
  21.  
  22. # the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
  23. If {Echo} == 1
  24.     Set somewhere "∑∑ '{Worksheet}∂'"
  25. Else
  26.     Set somewhere '∑ Dev:Null'
  27. End
  28.  
  29. Begin
  30.  
  31.     Set OldComment "{SystemFolder}OldComment"
  32.     Set NewComment "{SystemFolder}NewComment"
  33.     Set CheckInErrors "{SystemFolder}CheckInErrors"
  34.     Set Window "{1}"
  35.  
  36.     # get short name of window
  37.  
  38.     If "{Window}" !~ /:*([¬:]+:*)*([¬:]+)®1/
  39.         Exit 1                            # bad window parameter
  40.     End
  41.     Set Short "{®1}"                    # get short name for dialogs
  42.     Set Cant "“{Short}” can’t be checked in"
  43.  
  44.     # check what project the window belongs to
  45.  
  46.     # *** what about a files that are new to a project?
  47.     Set Info "`ProjectInfo "{Window}"`"
  48.     Unset New
  49.     Unset Version
  50. ###    If "{Info}" !~ /≈Project: (≈∫)®1 ≈/
  51.     If "{Info}" !~ /≈Project: (≈)®1     Checked out: ≈/
  52.         If `Project` == ""
  53.             Alert "{Cant} because there are no projects mounted."
  54.             Exit 1
  55.         End
  56.  
  57.         Set New "-new -project `GetListItem -r 10 ∂`MountProject -pp -s -r∂` -d ∂`Project∂` ∂
  58.             -m "“{Short}” isn’t in a project. Choose one to add it to:" ; Set GetListItemStatus {Status}`"
  59.         If {GetListItemStatus} != 0
  60.             Exit 1
  61.         End
  62.  
  63.         If "{InitialVersion}" != ""
  64.             Set Version ",{InitialVersion}"
  65.         End
  66.     Else
  67.         Set Project "{®1}"
  68.  
  69.         # check if the project is mounted
  70.  
  71.         ProjectInfo -project "{Project}" -only
  72.         If {Status} != 0
  73.             Alert "{Cant} because the project “{Project}” is not mounted."
  74.             Exit 1
  75.         End
  76.  
  77.         # ensure that the window is checked out
  78.  
  79.         If "{Info}" !~ /[¬,]+,[¬ ∂t]+[∂+∂*]≈/
  80.             Alert "{Cant} because it wasn’t checked out."
  81.             Exit 1
  82.         End
  83.     End
  84.  
  85.     Echo -n >"{OldComment}"                    # start with an empty file
  86.     If {ProjectHeaders}
  87.         Mark -y § OldSelection "{Window}"    # mark the selection
  88.         GetLastChange "{Window}" "{OldComment}"
  89.     End
  90.     If ({Status} ≠ 0) || ¬ {ProjectHeaders}
  91.         Set Info "`ProjectInfo "{Window}" -comments`"
  92.         If "{Info}" =~ /≈Comment: +(≈)®1/
  93.             Echo -n "{®1}" >"{OldComment}"
  94.         End
  95.     End
  96.  
  97.     Set IgnoreCmdPeriod 1
  98.     CoolRequest -q -d "What did you change in “{Short}”?" <"{OldComment}" >"{NewComment}"
  99.     Set CommentStatus {Status}
  100.     Set IgnoreCmdPeriod 0
  101.     Equal -d -q "{OldComment}" "{NewComment}"
  102.     Set EqualStatus {Status}
  103.     Delete -i "{OldComment}"
  104.     If {CommentStatus} != 0
  105.         If {ProjectHeaders}
  106.             Find OldSelection "{Window}"
  107.             Unmark OldSelection "{Window}"
  108.         End
  109.         Delete -i "{NewComment}"
  110.         If {CommentStatus} == 4
  111.             Exit 4
  112.         End
  113.         Exit 1
  114.     End
  115.  
  116.     If {ProjectHeaders}
  117.         If {EqualStatus}
  118.             # add/modify a change in the change history
  119.  
  120.             Evaluate "`Files -n -q -x m "{Window}"`" =~ /[¬∂/]+ ([1-9]≈)®1/
  121.             Set Date "{®1}"                    # get date before adding change
  122.  
  123.             Clear LastChange "{Window}"        # get rid of old change
  124.             AddChange "{Window}" "{NewComment}"
  125.             Set AddChangeStatus {Status}    # remember if we canceled
  126.             Find • "{Window}"                # go to top
  127.             Replace -c ∞ /[ ∂t]+∞/ '' "{Window}"    # trim all trailing whitespace
  128.  
  129.             SetFile -m "{Date}" "{Window}"    # set date back to before change
  130.         End
  131.  
  132.         Find OldSelection "{Window}"
  133.         Unmark OldSelection "{Window}"
  134.  
  135.         Save "{Window}"                        # save before checking in
  136.  
  137.         If {AddChangeStatus} == 4
  138.             Exit 4
  139.         End
  140.     End
  141.  
  142.     # *** what about a way to keep working (keep the modifiable)?
  143.     # *** what about introducing a new branch?
  144.     # *** what about entering a "task"?
  145.     CheckIn {New} -cf "{NewComment}" "{Window}{Version}" ∑"{CheckInErrors}"
  146.     Set CheckInStatus {Status}
  147.     Delete -i "{NewComment}"
  148.     If {CheckInStatus} != 0
  149.         Alert "{Cant}. You may need to check it in on a branch.∂n`Catenate "{CheckInErrors}"`"
  150.         Exit 1
  151.     End
  152.     Delete -i "{CheckInErrors}"
  153.  
  154. End {somewhere}
  155.